package com.why.jvm.hotspot.src.share.vm.oops;

import com.why.jvm.hotspot.src.share.vm.oops.constants.ConstantUtf8Info;
import lombok.Data;

@Data
public class LocalVariableTable {

    private ConstantPool constantPool;

    private int startPc;

    private int length;

    private int nameIndex;

    private int descriptorIndex;

    private int index;


    public String getName(){
        return ((ConstantUtf8Info) constantPool.getConstantPoolMap().get(nameIndex)).getValue();
    }

    public String getDescriptor(){
        return ((ConstantUtf8Info) constantPool.getConstantPoolMap().get(descriptorIndex)).getValue();
    }

    @Override
    public String toString() {
        return "\n\t\tLocalVariableTable{" +
                "\n\t\t\tstartPc=" + startPc +
                "\n\t\t\tlength=" + length +
                "\n\t\t\tindex=" + index +
                "\n\t\t\tnameIndex=" + nameIndex +
                "\n\t\t\tname=" + getName() +
                "\n\t\t\tdescriptorIndex=" + descriptorIndex +
                "\n\t\t\tdescriptor=" + getDescriptor() +
                '}';
    }
}
